import {reactive, ref} from 'vue';

export const reactiveEx = function (reactiveObject, targetObject) {
  let origin = ref({});
  let _target = ref(reactiveObject)
  let merging = ref(targetObject)

  let result = reactive(Object.assign(origin.value, _target.value, merging.value));

  return result;
}

export class ReactiveEx {
  constructor(obj = {}) {
    this.origin = {}
    this.obj = obj;

    this.template = this._reactiveAssign(this.origin, this.obj);
  }

  assignObject(obj) {
    let objRef = obj;

    return this._reactiveAssign(this.origin, this.obj, objRef);
  }

  _reactiveAssign() {
    let args = arguments;
    return reactive(Object.assign.apply(this, args))
  }
}
